<{include file="common/header.tpl"}>
<section id="spread_one" class="column" style="width:100%">
<script type="text/javascript" src="/resource/js/common.js"></script>
        <script type="text/javascript">
        //预定参数
        var font_color = '#CE0000';
        var bg_observe = '#FFE4C4';
        var bg_unqualified = '#FFB5B5';
        var bg_ignore = 'skyBlue';
        var config = <{$config}>;
        var last_day = '<{$last_day}>';
        //搜索
        function search(action)
        {
            var obj = document.getElementById('search_form');
            obj.action = action;
            obj.submit();
        }
        //设置表格样式
        function set_td_style(obj)
        {
            var type = obj.attr('type');
            var val  = obj.text();
            if (type == undefined)
            {
                return;
            }
            //单元格样式（不合格项）
            if (config[type] != undefined)
            {
                if (val.replace(/[^0-9\.]/, '') < config[type]) obj.css('color', font_color);
            }
            //行样式
            else if(type == 'status')
            {
                if (val.indexOf('(已忽略)') != -1) obj.parent().css('background', bg_ignore);
                else if (val == '观察中') obj.parent().css('background', bg_observe);
                else if (val == '不合格')
                {
                    obj.parent().css('background', bg_unqualified);
                    //添加忽略按钮
                    if ($('#search_day').text().replace(/\//g, '-') == last_day)
                    {
                        obj.next().html('<input type="button" value="忽略" onclick="if(confirm(\'确定要忽略吗？\'))set_ignore(this);" />');
                    }
                }
            }
        }
        function set_ignore(obj)
        {
            var td = $(obj).parent().prev();
            $.get('/quality/set_ignore?id='+td.attr('aid'), function(data){
                if (!data.status) alert(data.msg);
                else
                {
                    td.html('合格(已忽略)');
                    td.next().html('-');
                    set_td_style(td);
                }
            }, 'json');
        }
        $(function(){
            //排序
            $('#tab1 th').click(function(){
                if ($(this).attr('order_by') != null)
                {
                    order_by($(this).attr('order_by'));
                }
            });
            //颜色标识
            $('#tab1 td').each(function(){
                set_td_style($(this));
            });
            //表格列宽度
            $('.tablesorter td').css({padding:'15px 5px', minWidth:'36px'});
        });
        </script>
        <div style="margin:10px 3% 0;padding:10px;background:#ECECEC;border:1px solid #E2E2E2;font-size:14px;">
            <form method='GET' action='online' id="search_form">
                日期：<input type="text" value="<{$query.day}>" id="date1" name='day' style="width:80px;" />
                &nbsp; 状态：<select name="status">
                     <option value="">全部</option>
                 <{foreach from=$status_arr key=k item=v}>
                     <option value="<{$k}>" <{if $query.status == $k}>selected<{/if}>><{$v}></option>
                 <{/foreach}>
                </select>
                &nbsp; 子渠道类型：<select name="sub_type">
                    <option value="">全部</option>
                     <option value="1" <{if 1 == $query.sub_type}>selected<{/if}>>线下刷机</option>
                     <option value="2" <{if 2 == $query.sub_type}>selected<{/if}>>线下内置</option>
                     <option value="3" <{if 3 == $query.sub_type}>selected<{/if}>>线上自有</option>
                     <option value="4" <{if 4 == $query.sub_type}>selected<{/if}>>线上换量</option>
                     <option value="5" <{if 5 == $query.sub_type}>selected<{/if}>>线上付费</option>
                     <option value="10" <{if 10 == $query.sub_type}>selected<{/if}>>历史遗留</option>
                </select>
                &nbsp; 筛选：<select name="search_key">
                     <option value="">全部</option>
                 <{foreach from=$allow_compare key=k item=v}>
                     <option value="<{$k}>" <{if $query.search_key == $k}>selected<{/if}>><{$v}></option>
                 <{/foreach}>
                </select>
                大于等于<input type="text" name="search_value" value="<{$query.search_value}>" size="10">
                <{if $user_info.passport == 'luyankai@哇吖.com' || $user_info.passport == 'yangxiaoliang2@哇吖.com' || $user_info.passport == 'yuancong@哇吖.com' }>
                <input class="effect-update" type='submit' value='查线上' onclick="search('online')" style="padding:3px 5px;">
                <input class="effect-update" type='submit' value='查线下' onclick="search('offline')" style="padding:3px 5px;">
                <{elseif $user_info.passport == 'zhaodongdong@哇吖.com'}>
                <input class="effect-update" type='submit' value='查询' onclick="search('online')" style="padding:3px 5px;">
                <{elseif $user_info.passport == 'jinmaomao@哇吖.com'}>
                <input class="effect-update" type='submit' value='查询' onclick="search('offline')" style="padding:3px 5px;">
                <{/if}>
            </form>
        </div>
        <div style="margin:10px 3% 0;padding:10px;background:#ECECEC;border:1px solid #E2E2E2;font-size:14px;height:30px;line-height:30px;">
            <div style="float:left;">每行不同的底色代表不同的意义，</div>
            <div style="float:left;background:#ffffff;height:30px;padding:0 5px;">无底色表示合格</div>
            <div style="float:left;background:#FFE4C4;height:30px;padding:0 5px;">淡黄表示观察中</div>
            <div style="float:left;background:#FFB5B5;height:30px;padding:0 5px;">淡红表示不合格</div>
            <div style="float:left;background:skyBlue;height:30px;padding:0 5px;">蓝色表示已忽略</div>
            <div style="float:left;color:#CE0000;height:30px;">红色文字表示该项未合格</div>
        </div>
        <article class="module width_3_quarter">
        <header>
            <h3 class="tabs_involved " style="width:300px;"><{$chntype}>渠道质量（<span id="search_day"><{$query.day}></span>）<span style="position:absolute;right: 7em;color:tomato;">共 <{$data_count}> 条记录</span></h3>
        </header>
        <div class="tab_container">
            <div id="tab1" class="tab_content">
            <table class="tablesorter" cellspacing="0"> 
            <thead>
                <tr>
                    <th>友盟ID</th>
                    <th>渠道KEY</th>
                    <th>渠道名</th>
                    <th>子分类</th>
                    <th>管理员</th>
                    <th order_by='retentionRate'>次日留存</th>
                    <th order_by='actusers'>活跃用户</th>
                    <th order_by='newusers'>日新增</th>
                    <th order_by='searchs'>日搜索</th>
                    <th order_by='downloads'>日下载</th>
                    <th order_by='lifetime'>日均时长</th>
                    <th order_by='avgDownload'>下载比例</th>
                    <th order_by='avgSearch'>搜索比例</th>
                    <th order_by='ratio'>建议系数</th>
                    <th order_by='status'>状态</th>
                    <th order_by='observe_days'>观察天数</th>
                </tr> 
            </thead> 
            <tbody>
                <{foreach from=$data item=v name=apps}>
             <tr>
                 <td><{$v.umeng_id}></td>
                 <td title="创建日期 <{$v.create_time}>"><{$v.unique_key}></td>
                 <td><{$v.name}></td>
                 <td><{$sub_type[$v.sub_type]}></td>
                 <td><{$v.manager_name}></td>
                 <td type='retentionRate'><{$v.retentionRate}>%</td>
                 <td><{$v.actusers}></td>
                 <td><{$v.newusers}></td>
                 <td><{$v.searchs}></td>
                 <td><{$v.downloads}></td>
                 <td type='lifetime'><{$v.lifetime}></td>
                 <td type='avgDownload'><{$v.avgDownload}></td>
                 <td type='avgSearch'><{$v.avgSearch}></td>
                 <td><{$v.ratio}></td>
                 <td type='status' aid="<{$v.id}>"><{$status_arr[$v.status]}><{if $v.ignore == 1}>(已忽略)<{/if}></td>
                 <td><{$v.observe_days}></td>
             </tr>
             <{/foreach}>
             <tr>
                 <td>合计</td>
                 <td>-</td>
                 <td>-</td>
                 <td>-</td>
                 <td>-</td>
                 <td>-</td>
                 <td><{$sum_data.actusers}></td>
                 <td><{$sum_data.newusers}></td>
                 <td><{$sum_data.searchs}></td>
                 <td><{$sum_data.downloads}></td>
                 <td>-</td>
                 <td>-</td>
                 <td>-</td>
                 <td>-</td>
                 <td>-</td>
                 <td>-</td>
             </tr>
                 <tr>
                    <td colspan="9">合计 <{$data_count}> 条记录</td>
                </tr>
            </tbody> 
            </table>
            </div><!-- end of #tab1 -->
        </div><!-- end of .tab_container -->
        </article><!-- end of content manager article -->
        <div class="clear"></div>
    </section>            
<{include file="common/footer.tpl"}>
